#coding=utf-8

import epics
import tornado
from controller.BaseHandler import BaseHandler
from controller import cagetDouble

class Handler(BaseHandler):

    @tornado.web.asynchronous
    @tornado.gen.coroutine
    def get(self):
        # 返回内容
        self.tplAssigns['LM01'] = yield self.backend.submit(epics.caget, 'EXP_IB_TA:TT:LM01:SW:bi')
        self.tplAssigns['LM02'] = yield self.backend.submit(epics.caget, 'EXP_IB_TA:TT:LM02:SW:bi')
        self.tplAssigns['THE_SV01']= yield self.backend.submit(epics.caget, 'EXP_TB_HV:ASS:THE_SV01:SW:bi')

        self.tplAssigns['doubleValues'] = []
        HWSPT06 = yield self.backend.submit(cagetDouble, 'EXP_TB_EU:HWS:HWSPT06:PRS:ai')
        self.tplAssigns['doubleValues'].append(['靶体冷却水进口压力', HWSPT06,  'Mpa'])
        HWSFT02 = yield self.backend.submit(cagetDouble, 'EXP_TB_EU:HWS:HWSFT02:FLW:ai')
        self.tplAssigns['doubleValues'].append(['靶体冷却水流量', HWSFT02, 'm³/h'])

        PS_T_PRS = yield self.backend.submit(cagetDouble, 'EXP_IB_TA:TT:PS_T:PRS:ai')
        self.tplAssigns['doubleValues'].append(['膨胀法兰供气压力', PS_T_PRS, 'Mpa'])
        self.render("ezca/target.html", **self.tplAssigns)
